﻿
using System.Collections;
using System.Xml;

namespace Xacml.Core.Policy
{
  public class ObligationCollectionReadWrite : CollectionBase
  {
    public virtual int Add(ObligationElementReadWrite value)
    {
      return this.List.Add((object) value);
    }

    public new virtual void Clear()
    {
      base.Clear();
    }

    public new virtual void RemoveAt(int index)
    {
      base.RemoveAt(index);
    }

    public void WriteDocument(XmlWriter writer)
    {
      if (this.Count <= 0)
        return;
      writer.WriteStartElement("Obligations");
      foreach (ObligationElementReadWrite elementReadWrite1 in (CollectionBase) this)
      {
        writer.WriteStartElement("Obligation");
        writer.WriteAttributeString("ObligationId", elementReadWrite1.ObligationId);
        writer.WriteAttributeString("FulfillOn", elementReadWrite1.FulfillOn.ToString());
        foreach (AttributeAssignmentElementReadWrite elementReadWrite2 in (CollectionBase) elementReadWrite1.AttributeAssignment)
        {
          writer.WriteStartElement("AttributeAssignment");
          writer.WriteAttributeString("AttributeId", elementReadWrite2.AttributeId);
          writer.WriteAttributeString("DataType", elementReadWrite2.DataTypeValue);
          writer.WriteString(elementReadWrite2.Value);
          writer.WriteEndElement();
        }
        writer.WriteEndElement();
      }
      writer.WriteEndElement();
    }
  }
}
